define(function(){
    class Index{
        constructor(options){
            this.p1 = options.op1
            this.p2 = options.op2
            this.span = options.ospan
            this.em = options.oem
    
            this.getLocal();
            this.login();
            this.addEvent();
        }
        getLocal(){
            // 之前有没有
            this.userMsg = localStorage.getItem("userMsg");
            this.userMsg = this.userMsg ? JSON.parse(this.userMsg) : [];
        }
        login(){
            this.i = 0;
            var o = this.userMsg.some((val,index)=>{
                this.i = index;
                return val.onoff == 1;
            })
            if(o){
                this.p1.style.display = "none";
                this.p2.style.display = "block";
                this.span.innerHTML = this.userMsg[this.i].user;
            }
        }
        addEvent(){
            var that = this;
            this.em.onclick = function(){
                that.userMsg[that.i].onoff = 0;
                localStorage.setItem("userMsg",JSON.stringify(that.userMsg));
                that.p1.style.display = "block";
                that.p2.style.display = "none";
                that.span.innerHTML = "";
            }
        }
    }
    
	return {
		ind1:Index
	}
});